package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.baseComponentPojo;
import com.example.pojo.productModelListPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName:baseComponentMapp
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/7/11 18:26
 * @Version 1.0
 */
@Mapper
public interface baseComponentMapp {
    //插入一条新的记录
    @DS("baodingRussia")
    @Insert("insert into base_component (partNumber, partName, partModel," +
            " supplier, sortIndex, establishTime, UpdateTime) " +
            "VALUES " +
            "(#{partNumber},#{partName},#{partModel,}," +
            "#{supplier},#{sortIndex},#{establishTime},#{UpdateTime})")
    void insertOne(baseComponentPojo baseComponent);
    //查询所有的数据
    @DS("baodingRussia")
    @Select("select * from base_component")
    List<baseComponentPojo> queryAll();
    //对零部件信息进行编辑
    @DS("baodingRussia")
    @Update("update base_component set " +
            "partNumber=#{partNumber}," +
            "partName=#{partName}," +
            "partModel=#{partModel}," +
            "supplier=#{supplier}," +
            "UpdateTime=#{UpdateTime}" +
            " where id=#{id}")
    void editOne(baseComponentPojo baseComponent);
    //筛选出最新写入的数据,利用的是Id最大筛选
    @DS("baodingRussia")
    @Select("SELECT *  FROM base_component ORDER BY id DESC LIMIT 1;")
    baseComponentPojo queryByIdMax();
    //辅助函数：对零部件信息进行调用,调用所有的信息
    @DS("newMscLowCodeFormal")
    @Select("select * From product_model_list")
    List<productModelListPojo> inquiryProductList();
}
